# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

_hkgname=X11-xft
pkgname=haskell-x11-xft
pkgver=0.3.4
pkgrel=46
pkgdesc="Bindings to the Xft and some Xrender parts"
url="https://github.com/xmonad/X11-xft"
license=('LGPL')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-x11' 'haskell-utf8-string' 'libxft')
makedepends=('ghc' 'uusi')
source=(https://hackage.haskell.org/packages/archive/X11-xft/$pkgver/X11-xft-$pkgver.tar.gz)
sha512sums=('cd7c10bbe21f096814ebbf1015f4492ee60e73032bbb114f8fa5684e46f96239814f6986d44955642509c06b790112a38194661754e23c874dfe9446b0c13eef')

prepare() {
    cd $_hkgname-$pkgver
    gen-setup
}

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
